package throw

import (
	"openapi.itspire.cn/common/dict"
	"github.com/gin-gonic/gin"
	"net/http"
	"openapi.itspire.cn/utils"
)

func ServerError(c *gin.Context, err string) {
	utils.Error(c, err, http.StatusInternalServerError, http.StatusInternalServerError, dict.LevelError)
}

func ParameterError(c *gin.Context, err string) {
	utils.Error(c, err, http.StatusBadRequest, http.StatusBadRequest, dict.LevelWarn)
}

func NotFound(c *gin.Context, err string) {
	utils.Error(c, err, http.StatusNotFound, http.StatusNotFound, dict.LevelWarn)
}

func LogicException(c *gin.Context, err string, code int)  {
	utils.Error(c, err, code, http.StatusOK, dict.LevelWarn)
}

func AuthException(c *gin.Context, err string)  {
	utils.Error(c, err, http.StatusUnauthorized, http.StatusUnauthorized, dict.LevelWarn)
}